#include "AppComponent.hpp"

#include <oatpp/network/Server.hpp>
#include <oatpp/core/macro/codegen.hpp>

#include "controller/MyController.hpp"

void run()
{
    AppComponent components;
    OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>,router);
    router->addController(std::make_shared<MyController>());
    OATPP_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>,connectionHandler,"http");
    OATPP_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>,connectionProvider);
    oatpp::network::Server server(connectionProvider,connectionHandler);
    OATPP_LOGI("MyApp","Server running on port %s",connectionProvider->getProperty("port").getData());
    server.run();
}

int main()
{
    oatpp::base::Environment::init();
    run();
    oatpp::base::Environment::destroy();
    return 0;
}